<template>
  <div>
    <eagle-tab-page-list
      url="/OtherDangerCheckTaskJG/GetPageData"
      :params="params"
      @initActive="_initActive"
      @initList="_initList"
    >
      <div v-if="this.active === 0">
        <eagle-cell class="card" v-for="(item, index) in list" :key="index">
          <eagle-tag
            v-if="item.Status === 10 && !item.IsExpire"
            class="info_tag"
            color="#1989fa"
            >进行中
          </eagle-tag>
          <eagle-tag
            v-if="item.Status === 10 && item.IsExpire"
            class="info_tag"
            type="danger"
            >已过期
          </eagle-tag>
          <div class="warn_item">
            <div @click="goDetail(item)">
              <eagle-row>
                <eagle-col span="24">
                  {{ index + 1 }}、{{ item.CheckTaskName }}</eagle-col
                >
              </eagle-row>
              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="20">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_enterprise.png"
                    alt=""
                  />{{ item.EnterpriseName }}
                </eagle-col>
              </eagle-row>

              <eagle-row gutter="24" class="dep_sort">
                <eagle-col span="20">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                    alt=""
                  />隐患类型：{{ item.CheckTypeName }}</eagle-col
                >
                <eagle-col span="10">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_danger.png"
                    alt=""
                  />隐患/检查：{{ item.HiddenDangerCnt }}/{{
                    item.CheckCnt
                  }}</eagle-col
                >
              </eagle-row>

              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />创建人：{{ item.CreateChnName }}
                </eagle-col>
              </eagle-row>

              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="24">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />{{ item.StartDate | formatDate }}至{{
                    item.EndDate | formatDate
                  }}</eagle-col
                >
              </eagle-row>
            </div>
             <div class="look-report" @click="userguanli(item)">
                <img
                  src="@/assets/Images/AppIcon/icon_list_verify.png"
                  alt=""
                />
                <span>验收人管理</span>
          </div>
          </div>
        </eagle-cell>
      </div>
      <div v-if="this.active === 1">
        <eagle-cell v-for="(item, index) in list" :key="index" class="card">
          <eagle-tag v-if="item.Status == 0" class="info_tag" color="grey"
            >未开始</eagle-tag
          >
          <div class="warn_item">
            <div @click="goDetail(item)">
              <eagle-row>
                <eagle-col span="24">
                  {{ index + 1 }}、{{ item.CheckTaskName }}</eagle-col
                >
              </eagle-row>

              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                    alt=""
                  />{{ item.CheckTypeName }}</eagle-col
                >
                <eagle-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_danger.png"
                    alt=""
                  />隐患/检查：{{ item.HiddenDangerCnt }}/{{
                    item.CheckCnt
                  }}</eagle-col
                >
              </eagle-row>

              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />创建人：{{ item.CreateChnName }}</eagle-col
                >
              </eagle-row>

              <eagle-row gutter="20" class="dep_sort">
                <eagle-col span="24">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />{{ item.StartDate | formatDate }}至{{
                    item.EndDate | formatDate
                  }}</eagle-col
                >
              </eagle-row>
            </div>
          </div>
        </eagle-cell>
      </div>
    </eagle-tab-page-list>
  </div>
</template>

<script>
// import { list } from "@/api/dangerCheckTask";
import { getDateTime } from "@/utils/getDate";
export default {
  data() {
    return {
      active: 0,
      list: [],
      params: [
        {
          title: "待验收任务",
          dataType: "NotVerify",
          badge: true,
        },
        {
          title: "验收完成任务",
          dataType: "Verified",
          badge: false,
        },
      ],
    };
  },
  filters: {
    formatDate: function (value, args) {
      return getDateTime(value);
    },
  },
  methods: {
    _initActive(active) {
      this.active = active;
    },
    _initList(list) {
      this.list = list;
    },

    goDetail(item) {
      this.$router.push({
        path: "/OtherDanger/DangerCheckTaskEdit",
        query: { id: item.ID },
      });
    },

    goFinishDetail(item) {
      this.$router.push({
        path: "/OtherDanger/DangerCheckTaskView",
        query: { id: item.ID },
      });
    },

    getFile(equipmentCode) {
      this.$router.push({
        path: "/Equipment/safetyfile",
        query: { equipmentCode: equipmentCode },
      });
    },
    userguanli(item) {
      this.$router.push(
        "/OtherDanger/checkVerifyuserList?taskId=" + item.ID
      );
    },
    // 编辑设备信息
    edit(equipmentCode) {
      this.$router.push({
        path: "/Equipment/Edit",
        query: { equipmentCode: equipmentCode },
      });
      this.$router.push("");
    },
    // 设备检验
    editCheck(equipmentCode) {
      this.$router.push({
        path: "/Equipment/editcheck",
        query: { equipmentCode: equipmentCode },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.all_dep {
  background-color: #ffffff;
}

.warn_header {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 10px;
  .warn_tag {
    position: absolute;
    right: 0;
    top: 0;
    border-radius: 26.64rem 0 0 26.64rem;
  }
}
.dep_sort {
  // display: flex;
  // flex-wrap: wrap;
  // margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}
.dep_btm {
  display: flex;
  justify-content: flex-end;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}
.look-report {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 10px;

  font-size: 12px;
  color: #666;
  border-top: 1px solid #eee;
}
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }

</style>
